{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-page white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$back}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>修改姓名</span></div>
                <div class="right"></div>
            </div>
        </div>
        <div class="page-content padding-bottom50 ">
            <div class="edit-name row">
                <div class="col-70">
                    <form name="form" action="" id="saveName" method="post" onsubmit="return false;" >
                        <input type="text" name="name" placeholder="请输入昵称..." />
                        <p class="row segmented-round">
                            <button onclick="" class="col button button-big button-fill" style="background:#66ba61;">保存修改</button>
                        </p>
                    </form>
                </div>
            </div>

        </div>



    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript">
    var ajaxOn = false ;
    $().ready(function () {
        $("#saveName").validate({
            rules: {
                name: "required"
            },
            messages: {
                name: '请输入昵称'
            },
            showErrors: function (errorMap, errorList) {
                $.each(errorList, function (i, v) {
                    messageToast( v.message );
                    return false;
                });
            },
            onfocusout: false,
            onsubmit : true ,
            onkeyup : false ,
            onclick : false ,
            focusInvalid:false,
            submitHandler:function(form){
                if (ajaxOn) {
                    return false ;
                }
                ajaxOn = true ;
                $.post("", $("#saveName").serialize(), function(data){
                    messageToast( data.info );
                    if (data.status == 'y') {
                        setTimeout(function(){
                            self.location = "{:url('info')}";
                        },1000);
                    }
                    ajaxOn = false ;
                }, 'json');

                return false ;

            }
        });
    });
</script>
{/block}